﻿@using Dentiste.Domain
@using Dentiste.Domain.Interfaces
@model Dentiste.Domain.Interfaces.IInami
@{
    ViewBag.Title = "Gestion inami";
    ViewBag.BodyId = "inamiManager";
    Layout = "../_Layout.cshtml";
}

@if (!String.IsNullOrEmpty(Request.QueryString["success"]))
{
    if (Request.QueryString["success"] == "true")
    {
        <div class="alert alert-success">
            Code ajout&eacute; avec <strong>succ&egrave;s</strong> !
        </div>
    }
    else
    {
        <div class="alert alert-error">
            Une <strong>erreur</strong> est survenue. Le code existe-t-il d&eacute;j&agrave; ?
        </div>
    }
}

<h2>Editer un code Inami</h2>
@if (Model == null)
{
    <form action="#">
        <fieldset>
            <legend>S&eacute;lectionner un code &agrave; &eacute;diter</legend>
            <select id="Code">
                @foreach (IInami i in DentisteManager.Instance.SelectAllInami())
                {
                    <option value="@i.Code">@i.Code - @i.Label</option>
                }
            </select>
            <button type="submit" class="btn btn-mini delete-btn" id="SelectEditInami">Editer ce code</button>
        </fieldset>
    </form>
}
else
{
    <form action="#">
        <button type="submit" class="btn add-btn" id="EditInami">Editer</button>
        <fieldset>
            <legend>Informations de base</legend>
            <label>Code</label>
            <div class="control-group">
                <input type="text" id="Code" placeholder="Code inami" disabled="disabled" value="@Model.Code"/>
                <span class="help-inline">Le champs est vide</span>
            </div>
        
            <label>Libel&eacute;</label>
            <div class="control-group">
                <input type="text" id="Label" placeholder="Libelé" value="@Model.Label"/>
                <span class="help-inline">Le champs est vide</span>
            </div>
        
            <legend>Tarification</legend>
            <div class="row">
                <div class="control-group span3">
                    <input type="text" id="Prix1" placeholder="Prix 1" value="@Model.Prix1">
                    <span class="help-inline" style="display: none;">Le champs est vide</span>
                </div>
                <div class="control-group span3">
                    <input type="text" id="Prix2" placeholder="Prix 2" value="@Model.Prix2">
                    <span class="help-inline" style="display: none;">Le champs est vide</span>
                </div>
                <div class="control-group span3">
                    <input type="text" id="Prix3" placeholder="Prix 3" value="@Model.Prix3">
                    <span class="help-inline" style="display: none;">Le champs est vide</span>
                </div>
            </div>
        
            <legend>Liaisons entre codes inami</legend>
            @{
                DbSetCustom<IInami> allInami = DentisteManager.Instance.SelectAllInami();
                IEnumerable<IInami> inamiDispo = allInami.Where(iRead => @Model.Code != iRead.Code && !@Model.RequiredInamis.Select(i => i.Code).Contains(iRead.Code));
            }
            @if (inamiDispo.Any())
            {
                <label>Codes inami requis</label>
                <select id="requiredSelect">
                    @{
                        foreach (IInami iRead in inamiDispo)
                        {
                            <option value="@iRead.Code">@iRead.Code - @iRead.Label</option>
                        }
                    }
                </select>
                <button class="btn btn-mini btn-success btnLink" type="button" id="linkCode">Lier</button>
            }
            @if (Model.RequiredInamis.Any())
            {
                <p>
                    Liste des codes li&eacute;s :
                </p>
                <ul id="requiredInamiList">
                    @foreach (IInami inami in @Model.RequiredInamis)
                    {
                        <li><a href="#@inami.Code" class="removeLink"><i class="icon-remove"></i></a> @inami.Code - @inami.Label</li>
                    }
                </ul>
            }
        </fieldset>
    </form>
}

@section Menu {
    <ul class="nav nav-pills">
        <li><a href="/">Encoder une d&eacute;claration de soin</a></li>
        <li class="dropdown active">
            <a class="dropdown-toggle" data-toggle="dropdown" href="#">
                G&eacute;rer les codes Inami
                <b class="caret"></b>
            </a>
            <ul class="dropdown-menu">
                <li><a href="/InamiManager/Add">Ajouter un nouveau code Inami</a></li>
                <li class="active"><a href="javascript:void(0)">Modifier un code Inami</a></li>
                <li><a href="/InamiManager/Delete">Supprimer un code Inami</a></li>
            </ul>
        </li>
    </ul>
}